<?php
/*
Primary Author: Alex Arey
Secondary: Derek Shue
Documentation: Cheng Yi
Updated: 12/10/2011
Module Description: The Partner Create Volunteer Form is used by Community Partners to request Volunteers.
*/
class Application_Form_PartnerCreateVolunteer extends Zend_Form
{
	
	private $contacts;
	
	public function __construct(array $params = array()) {
		$this->contacts = $params['contacts'];
		parent::__construct();
	}
	
    public function init()
    {
	
		$tagmodel = new Application_Model_DbTable_Tagnames();
		$tags = $tagmodel -> getAllTagnames();

		$tagoptions = array();

		if($tags){
		foreach($tags as $tag){
			$tagoptions[$tag['TAGNAME']] = $tag['TAGNAME'];
		}
		}
	
        $this->setMethod('post');

		
// $term = new Application_Model_Term();
// $options = $term->getAllTerms();
// $termoptions = array();
// foreach($options as $opt){
// 	$termoptions[$opt['TERM'] . $opt['YEAR'] ] = $opt['TERM'].$opt['YEAR'];
// }

		$nameLenValid = new Zend_Validate_StringLength(array('max' => 30));
		$veryLongTextLenValid = new Zend_Validate_StringLength(array('max' => 1000));
		$phonevalid = new Zend_Validate_Regex(array(
					'pattern' => '/^\d\d\\\d\d-\d\d\d\d$/'));
		$phonevalid->setMessages(array(
						'regexNotMatch'=>'Invalid Phone Number Format. Valid is (###)###-####'));
		$datevalid = new Zend_Validate_Regex(array(
					'pattern' => '/^((1[012])|(0\d))\/((3[01])|([012]\d))\/\d\d\d\d$/'));
		$datevalid->setMessages(array(
						'regexNotMatch'=>'Invalid Date Format. Valid is MM/DD/YYYY'));
		
	$this->addElement('text','POSITIONTITLE',array(
	    'label' => 'Position Title:',
        'required' => true,
        'validators'=>array($nameLenValid),
	    'filters' => array('StringTrim')
	    )
	);
// 	$this->addElement('hidden','TERM',array(
// 	    'label' => 'Term Requested For:',
// 		'multioptions' => $termoptions,
// 	    'filters' => array('StringTrim'),
// 		'required' => true,
// 	    )
// 	);

	$this->addElement('text','NUMBERREQUESTING',array(
	    'label' => 'Number of Volunteers Requested:',
        'required' => true,
	    'validators' => array('Digits', $nameLenValid)
	    )
	);

	$this->addElement('textarea','DESCRIPTION',array(
	    'label' => 'Position Description:',
            'required' => true,
            'validators'=>array($veryLongTextLenValid),
	    'filters' => array('StringTrim')
	    )
	);
	
	$this->addElement('select','sitesupervisor',array(
				'label' => 'Site Supervisor',
				'required=>true',
				'filters' => array('StringTrim'),
				'multioptions' => $this->contacts
	)
	);

	$this->addElement('multiCheckbox','requirements',array(
	    'label' => 'Special Requirements:',
	    'multiOptions'=>array(
		'REQVEHICLE' => 'Access To Vehicle',
		'REQBGCHECK' => 'Background Check',
		'REQHEAVYLIFTING' => 'Heavy Lifting',
		'REQINTERVIEW' => 'Interview',
		'REQSPANISH' => 'Spanish Proficiency',
		'REQTBTEST'  => 'TB Test'
	        )
	    )
	);

	$this->addElement('textarea','REQOTHERDESC',array(
	    'label' => 'Other Requriements:',
	    'filters' => array('StringTrim'),
	    'validators'=>array($veryLongTextLenValid),
	    )
	);

	$this->addElement('multiCheckbox', 'TAGNAMES', array('label'=>'Associated Tags:','multiOptions'=> $tagoptions, 'required'=>false));

	
	$this->addElement('submit','submit',array(
	    'label' => 'Submit Request')
	);
	
	$this->addElement('hidden','TERM');

    }
}

